<%@ Page Language="C#" Inherits="BOSS.Web.BaseViewPage<BOSS.Framework.Search.Result.ISearchResult>" %>
<%@ Import Namespace="BOSS.Domain.Customers" %>
<%@ Import Namespace="BOSS.Web.Extensions" %>

<%
    if (Model != null)
    {
        var data = Model.UnderlayerItems.OfType<CustomerAccount>().Select(x => new
        {
            Id = x.Id,
            AccountNumber = x.AccountNumber,
            Customer = new
            {
                Id = x.Customer.Id,
                Name = x.Customer.Name
            },
            Items = x.Items.Select(y=> new {
                Id = y.Product.Id,
                Name = y.Product.Name,
                Model = y.Product.Model,
                ChargedBalance = y.ChargedBalance,
                DonatedBalance = y.DonatedBalance,
                TotalBalance = y.ChargedBalance + y.DonatedBalance
            })
        });
%>
<%= Html.ToJson(data)%>
<%
    }
%>